FROM golang:1.24-alpine AS builder

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
RUN true \
  && apk add -U --no-cache ca-certificates git binutils

ADD . /build
WORKDIR /build

ENV CGO_ENABLED=0 \
    GO111MODULE=on \
    GOPROXY=https://goproxy.cn,direct

RUN go build -o drone-tree-config /build/cmd/drone-tree-config/main.go

# ---

FROM alpine

WORKDIR /app

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
RUN apk add -U --no-cache ca-certificates tzdata git

COPY --from=builder /build/drone-tree-config /app

CMD /app/drone-tree-config
